package cn.edu.ahstu.hive;

import org.apache.hadoop.hive.ql.exec.UDF;

public class UDFTest extends UDF {

	public int evaluate(int v1,int v2) {
		  return v1>v2?v2:v2;
		}
		//192.168.3.12=>192.168.003.012
		public String evaluate(String ip){
		  String[] split = ip.split("\\.");
		  StringBuffer sb=new StringBuffer();
		  for(String s:split){
		        String tmp="000"+s;
		        sb.append(tmp.substring(tmp.length()-3)).append(".");
		  }
		  return sb.substring(0,sb.length()-1);
		}
		public static void main(String[] args) {
		  UDFTest mu=new UDFTest();
		  System.out.println(mu.evaluate(3, 5));
		  System.out.println(mu.evaluate("192.168.3.12"));
		}
}
